package org.marverse.universe.modules

import scala.collection.Map
import scala.collection.mutable.HashMap
import persistance.PId
import scripting.{Type, UncheckedLiteralExpr}
import scripting.ScriptingUtil._
import util.Checkable

class Module(val pid: PId) extends Checkable {
  def members(implicit ctx: MutableTypedMap[TypedKey, Any]) = 
    ctx(Universe)(Modules)(this).members
  
  override def check(implicit ctx: MutableTypedMap[TypedKey, Any]) {
    // TODO
  }
}

object Module {
  
  class State {
    private[Module] val mutableMembers = HashMap[Symbol, UncheckedLiteralExpr]()
    val members: Map[Symbol, UncheckedLiteralExpr] = mutableMembers.readOnly
    
    private def this(previous: State) {
      this()
      mutableMembers ++= previous.members
    }
    
    def advance = new State(this)
  }
  
}
